package com.easyselection.controller;


import com.easyselection.dto.Result;
import com.easyselection.service.IVoucherOrderService;
import com.easyselection.service.impl.VoucherOrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/voucher-order")
public class VoucherOrderController {

    @Autowired
    private IVoucherOrderService voucherOrderService;
    @PostMapping("seckill/{id}")
    public Result seckillVoucher(@PathVariable("id") Long voucherId) {

        //异步秒杀下单 判断库存和一人一单问题放在redis当中, 创建订单则放入到阻塞队列中
        return voucherOrderService.seckillVoucherAsync(voucherId);

        //return voucherOrderService.seckillVoucher(voucherId);
    }
}
